package com.dart.sys.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dart.commons.base.web.util.PageParamsThreadLocal;
import com.dart.framework.exception.DataBaseException;
import com.dart.sys.entity.SysOperateLog;
import com.dart.sys.mapper.SysOperateLogMapper;
import com.dart.sys.service.SysOperateLogService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

@Service
public class SysOperateLogServiceImpl implements SysOperateLogService {

	@Autowired
	private SysOperateLogMapper mapper ;
	
	@Override
	public int insertLog(SysOperateLog entity) throws DataBaseException {
		try {
			return this.mapper.insertLog(entity);
		} catch (DataBaseException e) {
			throw new DataBaseException() ;
		} 
	}

	@Override
	public int deleteLog(Integer id) {
		return this.mapper.deleteLog(id);
	}
	
	@Override
	public SysOperateLog selectLogById(Integer id) {
		return this.mapper.selectLogById(id);
	}

	@Override
	public PageInfo<SysOperateLog> selectPageLog(SysOperateLog entity) {
		Page<SysOperateLog> page = PageHelper.startPage(PageParamsThreadLocal.getPageNum(), PageParamsThreadLocal.getPageSize(), "desc create_time") ;
		page.clear();
		this.mapper.selectPageLog(entity);
		return new PageInfo<SysOperateLog>(page) ;
	}

}
